<?php
/****************************************************************************
 *	Filename:       header.php
 *	Description:  	 
 *                      
 *	Notes:		    
 *	
 *	Author:		
 *  Date Created:	04/1/2013
 *	Date Last Edited/By: PK - 4/20/2013:  Minor formatting
 ****************************************************************************/

session_start();

function curPageURL() {
    $pageURL = 'http';
    if ($_SERVER["HTTPS"] == "on") {
        $pageURL .= "s";
    } //ifT
    $pageURL .= "://";
    if ($_SERVER["SERVER_PORT"] != "80") {
        $pageURL .= $_SERVER["SERVER_NAME"] . ":" . $_SERVER["SERVER_PORT"] . $_SERVER["REQUEST_URI"];
    } else {
        $pageURL .= $_SERVER["SERVER_NAME"] . $_SERVER["REQUEST_URI"];
    } //else
    return $pageURL;
} //function curPageURL
?>
<!DOCTYPE html>
<html lang="en"><head><meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
        <meta charset="utf-8">
        <title>CirclePoint Hotels</title>
        <meta name="viewport" content="width=device-width, initial-scale=1.0">
        <meta name="description" content="">
        <meta name="author" content="">

        <link href="css/bootstrap.css" rel="stylesheet">
        <link href="css/datepicker.css" rel="stylesheet">
        <link href="css/bootstrap-responsive.css" rel="stylesheet">
        <script src="./js/jquery.js"></script>
        <script type="text/javascript" src="//cdnjs.cloudflare.com/ajax/libs/handlebars.js/1.0.0-rc.3/handlebars.min.js"></script>
        <style type="text/css">
            body {
                padding-top: 60px;
                padding-bottom: 40px;
            }
            html,
            body {
                height: 100%;
            }

            #wrap {
                min-height: 100%;
                height: auto !important;
                height: 100%;
                margin: 0 auto -60px;
            }
            #push,
            #footer {
                height: 60px;
            }
        </style>


        <script type="text/javascript">

            function initButtons() {
                $("#login").click(function() {

                    username = $("#Email").val();
                    password = $("#Password").val();
                    $.ajax({
                        type: "POST",
                        url: "db/login.php",
                        data: "email=" + username + "&pwd=" + password,
                        success: function(html) {
                            if (html.indexOf("error") == -1) {
                                $("#divlogin").html(html);
                                initButtons();
                            } else
                                $('#login').popover('show');
                        } //function
                    }); //ajax
                    return false;
                });
                $("#logout").click(function() {

                    username = $("#Email").val();
                    password = $("#Password").val();
                    $.ajax({
                        type: "POST",
                        url: "db/login.php",
                        data: "logout=true",
                        success: function(html) {
                            $("#divlogin").html(html);
                            initButtons();
                        }
                    });
                    return false;
                });
            } //function initButtons() 

            $(document).ready(function() {
                initButtons();
            });
        </script>

    </head>

    <body>

        <div class="navbar navbar-inverse navbar-fixed-top">
            <div class="navbar-inner">
                <div class="container">
                    <button type="button" class="btn btn-navbar" data-toggle="collapse" data-target=".nav-collapse">
                        <span class="icon-bar"></span>
                        <span class="icon-bar"></span>
                        <span class="icon-bar"></span>
                    </button>
                    <a class="brand" href="/">CirclePoint Hotels</a>
                    <div class="nav-collapse collapse">
                        <ul class="nav">
                            <li<?php if (basename(parse_url($_SERVER['REQUEST_URI'], PHP_URL_PATH)) == "") echo " class='active'"; ?>><a href=".">Home</a></li>
                            <li<?php if (basename(parse_url($_SERVER['REQUEST_URI'], PHP_URL_PATH)) == "about.php") echo " class='active'"; ?>><a href="about.php">About</a></li>
                            <li<?php if (basename(parse_url($_SERVER['REQUEST_URI'], PHP_URL_PATH)) == "locations.php") echo " class='active'"; ?>><a href="locations.php">Locations</a></li>                     
                            <li<?php if (basename(parse_url($_SERVER['REQUEST_URI'], PHP_URL_PATH)) == "contact.php") echo " class='active'"; ?>><a href="contact.php">Contact</a></li>
                            <li<?php if (basename(parse_url($_SERVER['REQUEST_URI'], PHP_URL_PATH)) == "register.php") echo " class='active'"; ?>><a href="register.php">Register</a></li>
                        </ul><div id="divlogin">
                            <?php include('db/inclogin.php'); ?></div>
                    </div>
                </div>
            </div>
        </div>

        <div class="container" style="margin-top: 15px">